<?php

class SystemConfigController extends BaseController {

	public function __construct() {
		parent::__construct();
	}

	public function edit() {
		header("Content-type:text/html;charset=utf-8");
		$manager = new systemConfigManager();
		$manager->getSystemConfig();
		$this->tpl->assign('systemConfigList', $manager->configList);
		$this->tpl->assign('configTitleList', $manager->configTitleList);
		$this->tpl->display("systemConfig/edit.html");
	}

	public function editAction() {
		$manager = new systemConfigManager();
		$configStr = $manager->formatData();
		$msg = $manager->saveSystemConfig($configStr);
		$userid = Handler_http::getSession('PHPSESSID');
		$row_user = AdminLoginModule::select_cookie($userid);
		LogManager::writeAuditLog($row_user['id'], $row_user['username'], 0, 3, 2);
		Handler_tool::alertAndRedirect($msg, HTTPFILEURL . '/systemConfig/edit/');
	}

	public function applyAction() {
		exec("/sbin/reboot");
		Handler_tool::alertAndGoBack("成功调用命令!");
	}

}
